package com.dataseek.iot.device.controller;

import com.dataseek.iot.device.oss.FileUploadService;
import com.dataseek.iot.toolikit.common.enums.RspStatusEnum;
import com.dataseek.iot.toolikit.common.response.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@CrossOrigin
@Slf4j
@RequestMapping("**/uploadFile")
public class UploadController {
    @Autowired
    FileUploadService fileUploadService;

    @RequestMapping(value = "/upload", method = RequestMethod.POST)
    public ResponseResult upload(MultipartFile file) throws IOException {
        String uploadUrl = fileUploadService.upload(file);
        return new ResponseResult(RspStatusEnum.SUCCESS.getCode(),"成功", uploadUrl);
    }




}
